added samples
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / CSWebBrowserWithProxy / NativeMethods.cs
blob2fe07a2deddf6788a4c6d4998c0a2a4fb7bb0467
1 /****************************** Module Header ******************************\
2 Module Name: NativeMethods.cs
3 Project: CSWebBrowserWithProxy
4 Copyright (c) Microsoft Corporation.
6 This class is a simple .NET wrapper of wininet.dll. It contains 4 extern
7 methods in wininet.dll. They are InternetOpen, InternetCloseHandle,
8 InternetSetOption and InternetQueryOption.
10 This source is subject to the Microsoft Public License.
11 See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
12 All other rights reserved.
14 THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
15 EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
17 \***************************************************************************/
19 using System;
20 using System.Runtime.InteropServices;
22 namespace CSWebBrowserWithProxy
24 internal static class NativeMethods
26 /// <summary>
27 /// Initialize an application's use of the WinINet functions.
28 /// See
29 /// </summary>
30 [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)]
31 internal static extern IntPtr InternetOpen(
32 string lpszAgent,
33 int dwAccessType,
34 string lpszProxyName,
35 string lpszProxyBypass,
36 int dwFlags);
38 /// <summary>
39 /// Close a single Internet handle.
40 /// </summary>
41 [DllImport("wininet.dll", SetLastError = true)]
42 [return: MarshalAs(UnmanagedType.Bool)]
43 internal static extern bool InternetCloseHandle(IntPtr hInternet);
45 /// <summary>
46 /// Sets an Internet option.
47 /// </summary>
48 [DllImport("wininet.dll", CharSet = CharSet.Ansi, SetLastError = true)]
49 internal static extern bool InternetSetOption(
50 IntPtr hInternet,
51 INTERNET_OPTION dwOption,
52 IntPtr lpBuffer,
53 int lpdwBufferLength);
55 /// <summary>
56 /// Queries an Internet option on the specified handle. The Handle will be always 0.
57 /// </summary>
58 [DllImport("wininet.dll", CharSet = CharSet.Ansi, SetLastError = true)]
59 internal extern static bool InternetQueryOption(
60 IntPtr hInternet,
61 INTERNET_OPTION dwOption,
62 ref INTERNET_PER_CONN_OPTION_LIST OptionList,
63 ref int lpdwBufferLength);